package com.jsrana.idea.plugin.ideaweather.widget;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.StatusBarWidget;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.awt.event.MouseEvent;

/**
 * Created by jrana on 7/14/14.
 */
public class StatusWidget
        implements StatusBarWidget {
    private Project project;
    private String currentStatus = "Loading Weather...";
    private final WidgetPresentation presentation = new StatusPresentation();

    @NotNull
    public String ID() {
        return "IdeaWeather_StatusWidget";
    }

    public void setText( String message ) {
        currentStatus = message;
    }

    public Project getProject() {
        return project;
    }

    public void setProject( Project project ) {
        this.project = project;
    }

    @Nullable
    public WidgetPresentation getPresentation( @NotNull PlatformType platformType ) {
        return presentation;
    }

    public void install( @NotNull StatusBar statusBar ) {

    }

    public void dispose() {

    }

    class StatusPresentation
            implements TextPresentation {
        @Override
        public float getAlignment() {
            return -1;
        }

        @NotNull
        @Override
        public String getText() {
            return currentStatus;
        }

        @NotNull
        @Override
        public String getMaxPossibleText() {
            return "Weather";
        }

        @Override
        public String getTooltipText() {
            return "Click to view weather";
        }

        @Override
        public Consumer<MouseEvent> getClickConsumer() {
            return null;
        }

/*
        @NotNull @Override
        public Icon getIcon() {
            return new ImageIcon( getClass().getResource( "/resources/simple_weather_icon_01.png" ) );
        }
*/
    }
}
